package com.wyh.service;

import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;

/**
 * @author wuyuhan
 * @date 2021/1/15 16:50
 */
@Service
public class HelloServiceImpl implements HelloService {
    @Override
    @Adaptive
    public String sayHello(String name) {
        return "hello:"+name;
    }

    @Override
    public String methodA(String a) {
        System.out.println("methodA");
        sleep();
        return "methodA";
    }

    @Override
    public String methodB(String b) {
        System.out.println("methodB");
        sleep();
        return "methodB";
    }

    @Override
    public String methodC(String c) {
        System.out.println("methodC");
        sleep();
        return "methodC";
    }

    private void sleep() {
        int random = (int)(Math.random() * 100);
        try {
            Thread.sleep(random);
        } catch (Exception e) {

        }
    }
}
